# == Schema Information
#
# Table name: contacts
#
#  id              :integer(4)      not null, primary key
#  name            :string(255)
#  address         :string(255)
#  tel             :string(255)
#  email           :string(255)
#  passport_number :string(255)
#  content         :text
#  business_type   :string(255)
#  created_at      :datetime
#  updated_at      :datetime
#

class Contact < ActiveRecord::Base

  validates_uniqueness_of :email,:tel

  validates_presence_of :name ,:email

  validates_length_of :name ,:email  , :maximum => 200
  validates_length_of :content , :maximum => 20000
  validates_format_of :email, :unless => Proc.new{|p|p.email.blank?}, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i
#  validates_presence_of :address , :unless => Proc.new{|p| p.business_type == 'その他お問い合わせ' }
#  validates_presence_of :tel , :unless => Proc.new{|p| p.business_type == 'その他お問い合わせ' }
  #  validates_presence_of :passport_number , :unless => Proc.new{|p| p.business_type == 'その他お問い合わせ' }
#  validates_length_of :address , :maximum => 200, :unless => Proc.new{|p| p.business_type == 'その他お問い合わせ' }
#  validates_length_of :tel, :maximum => 200 , :unless => Proc.new{|p| p.business_type == 'その他お問い合わせ' }
#  validates_length_of :passport_number , :maximum => 200 , :unless => Proc.new{|p| p.business_type == 'その他お問い合わせ' }



end
